package com.itmg.analyze.jp.url.impl;

import org.apache.log4j.Logger;

import com.itmg.analyze.jp.bean.AmazonParaBean;
import com.itmg.analyze.jp.model.AmazonSearchParamModel;
import com.itmg.analyze.jp.url.IURLAnalyze;
import com.itmg.vo.SearchParameterVO;
import com.itmg.vo.TargetDataVO;

/**
 *  获得 Amazon  匹配好的URL
 * @author Yunhong Chen
 * */
public class AmazonURlAnlyzeImpl implements IURLAnalyze {
	
	protected Logger log = Logger.getLogger(AmazonURlAnlyzeImpl.class.getName());
	private String rootURL = "http://ecs.amazonaws.jp/onca/xml";
	private String service = "AWSECommerceService";
	private String aWSAccessKeyId="09M2ES8KM23JXXFVQQR2";
	private String operation="ItemSearch";
	private String condition="All";
	private String responseGroup="ItemAttributes,Images";
//	private String searchIndex;
	private String sourceSiteName = "amazon.co.jp";
	private String itemPage;
	private String version="2008-08-19";
	
	public AmazonURlAnlyzeImpl(){
		
	}

	public TargetDataVO getURLDataByParameter(SearchParameterVO searchParameterVO) throws Exception {
		AmazonSearchParamModel amazonSearchParamModel = AmazonParaBean.getAmazonSearchParamModel(searchParameterVO);
		amazonSearchParamModel.setService(service);
		amazonSearchParamModel.setAWSAccessKeyId(aWSAccessKeyId);
		amazonSearchParamModel.setOperation(operation);
		amazonSearchParamModel.setCondition(condition);
		amazonSearchParamModel.setResponseGroup(responseGroup);
		amazonSearchParamModel.setSearchIndex(searchParameterVO.getSearchIndex());
		amazonSearchParamModel.setItemPage(itemPage);
		amazonSearchParamModel.setVersion(version);
		TargetDataVO targetDataVO = new TargetDataVO();
		targetDataVO.setSourceSiteName(sourceSiteName);
		targetDataVO.setUrl(rootURL+amazonSearchParamModel.getURLPara());
log.info(targetDataVO.getUrl());
		return targetDataVO;
	}

}
